package cn.ejiakanghu.logistics.third.shunfeng;

import org.linlinjava.litemall.core.util.IdWorkerUtils;
import org.linlinjava.litemall.db.vo.logistics.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * 参数名 	   必选  类型 	长度 	说明
 * isGenBillNo 	否 	string 	10 	是否生成运单号 2：不生成运单号，其他：生成运单号
 * mailno 	条件 	string 	20 	运单号 是否生成运单号为2时，必填
 * masterMailno 	条件 	string 	50 	母单号 是否生成运单号为2时，必填
 * mainMailno 	否 	string 	1024 	批次号
 * boxNo 	是 	string 	50 	客户订单号（箱号），可以多个拼接
 * dispatchNo 	是 	string 	20 	派单号 如没有，则填“客户订单号”
 * storeId 	是 	string 	20 	门店ID，如果没有门店ID，则填写组织编码
 * storeName 	否 	string 	20 	门店名称
 * custCode 	否 	string 	20 	商户ID
 * custName 	否 	string 	20 	商户名称
 * count 	是 	string 	10 	件数
 * goodsCount 	否 	string 	10 	物品件数 每件包含的物品数量
 * weight 	否 	string 	20 	重量
 * dcontact 	是 	string 	20 	收件人
 * dtel 	是 	string 	20 	收件电话
 * daddress 	是 	string 	256 	收件地址 省+市+区+具体地址
 * dcompany 	否 	string 	50 	收件公司
 * jcontact 	是 	string 	20 	寄件人
 * jtel 	是 	string 	20 	寄件电话
 * jaddress 	是 	string 	256 	寄件地址 省+市+区+具体地址
 * jcompany 	否 	string 	50 	寄件公司
 * cargo 	是 	string 	50 	拖寄物
 * payMethod 	是 	string 	10 	付款方式 1：寄方付 2：收方付 3:第三方付
 * custId 	否 	string 	20 	月结账号
 * expressType 	是 	string 	5 	产品类型 1：顺丰特快 2：顺丰标快等
 * isCod 	否 	string 	5 	是否代收货款 1：代收货款，其他：不是代收货款
 * collectingMoney 	条件 	double 	（10,2） 	代收货款金额 是否代收货款为1时，必填
 * collectingCardNumber 	条件 	string 	20 	代收卡号 是否代收货款为1时，必填
 * isReturnTracking 	否 	string 	5 	是否生成签回单 1：生成签回单号，其他：不生成签回单号
 * custPayTime 	是 	string 	50 	客户支付时间 格式为：2019-04-21 14:42:27 如无支付时间，则当前时间
 * orderRemark 	否 	string 	256 	备注
 * isMerge 	否 	string 	5 	是否合并订单 1：合并，其他：不合并
 * destCode 	否 	string 	50 	目的地代码
 * addedServiceName 	否 	string 	50 	增值服务名称
 * addedServiceValue 	否 	string 	50 	增值服务扩展属性
 * addedServiceValue1 	否 	string 	50 	增值服务扩展属性1
 * organizationCode 	否 	string 	50 	组织编码
 * isDocall 	否 	string 	5 	是否下call 1：下call，其他：不下call
 * twoDimensionCode 	否 	string 	256 	二维码 如： MMM={‘k1’:’023W’,’k2’:’023DB’,’k3’:’’,’k4’:’T4’,’k5’:’444143702966’,’k6’:’’,’k7’:’5ede720f’}
 *
 * @author houzb
 * @Description
 * @create 2021-12-01 17:46
 */
public class ShunfengCreateOrderBody {
    private String isGenBillNo; //2",
    private String mailno; //444015570002",
    private String masterMailno; //444015570001"必
    private String mainMailno;
    private String boxNo; //test201907090048",
    private String dispatchNo; //CH4-1805113589",
    private String storeId; //1",
    private String storeName; //",
    private String custCode; //",
    private String custName; //",
    private String count; //1",
    private String goodsCount; //1",
    private String weight; //19.5",
    private String dcontact; //张三",
    private String dtel; //18000000000",
    private String daddress; //海南省海口市秀英区临秀大道287号",
    private String jcontact; //李四",
    private String jtel; //17000000000",
    private String jaddress; //重庆市市辖县忠县忠州街道中博香山湖31号楼",
    private String cargo; //文件",
    private String payMethod; //1",
    private String custId; //7551234567",
    private String expressType; //2",
    private String isCod; //0",
    private String collectingMoney; //": 20.0,
    private String collectingCardNumber; //11",
    private String isReturnTracking; //0",
    private String custPayTime; //2019-05-27 16:31:48",
    private String orderRemark; //",
    private String isMerge; //",
    private String destCode; //769",
    private String addedServiceName; //IN91",
    private String addedServiceValue; //12",
    private String addedServiceValue1; //1",
    private String organizationCode; //7311B",
    private String isDocall; //"

    public String getMainMailno() {
        return mainMailno;
    }

    public void setMainMailno(String mainMailno) {
        this.mainMailno = mainMailno;
    }

    public String getBoxNo() {
        return boxNo;
    }

    public void setBoxNo(String boxNo) {
        this.boxNo = boxNo;
    }

    public String getDispatchNo() {
        return dispatchNo;
    }

    public void setDispatchNo(String dispatchNo) {
        this.dispatchNo = dispatchNo;
    }

    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getCustCode() {
        return custCode;
    }

    public void setCustCode(String custCode) {
        this.custCode = custCode;
    }

    public String getCustName() {
        return custName;
    }

    public void setCustName(String custName) {
        this.custName = custName;
    }

    public String getCount() {
        return count;
    }

    public void setCount(String count) {
        this.count = count;
    }

    public String getGoodsCount() {
        return goodsCount;
    }

    public void setGoodsCount(String goodsCount) {
        this.goodsCount = goodsCount;
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight;
    }

    public String getDcontact() {
        return dcontact;
    }

    public void setDcontact(String dcontact) {
        this.dcontact = dcontact;
    }

    public String getDtel() {
        return dtel;
    }

    public void setDtel(String dtel) {
        this.dtel = dtel;
    }

    public String getDaddress() {
        return daddress;
    }

    public void setDaddress(String daddress) {
        this.daddress = daddress;
    }

    public String getJcontact() {
        return jcontact;
    }

    public void setJcontact(String jcontact) {
        this.jcontact = jcontact;
    }

    public String getJtel() {
        return jtel;
    }

    public void setJtel(String jtel) {
        this.jtel = jtel;
    }

    public String getJaddress() {
        return jaddress;
    }

    public void setJaddress(String jaddress) {
        this.jaddress = jaddress;
    }

    public String getCargo() {
        return cargo;
    }

    public void setCargo(String cargo) {
        this.cargo = cargo;
    }

    public String getPayMethod() {
        return payMethod;
    }

    public void setPayMethod(String payMethod) {
        this.payMethod = payMethod;
    }

    public String getCustId() {
        return custId;
    }

    public void setCustId(String custId) {
        this.custId = custId;
    }

    public String getExpressType() {
        return expressType;
    }

    public void setExpressType(String expressType) {
        this.expressType = expressType;
    }

    public String getIsCod() {
        return isCod;
    }

    public void setIsCod(String isCod) {
        this.isCod = isCod;
    }

    public String getCollectingMoney() {
        return collectingMoney;
    }

    public void setCollectingMoney(String collectingMoney) {
        this.collectingMoney = collectingMoney;
    }

    public String getCollectingCardNumber() {
        return collectingCardNumber;
    }

    public void setCollectingCardNumber(String collectingCardNumber) {
        this.collectingCardNumber = collectingCardNumber;
    }

    public String getIsReturnTracking() {
        return isReturnTracking;
    }

    public void setIsReturnTracking(String isReturnTracking) {
        this.isReturnTracking = isReturnTracking;
    }

    public String getCustPayTime() {
        return custPayTime;
    }

    public void setCustPayTime(String custPayTime) {
        this.custPayTime = custPayTime;
    }

    public String getOrderRemark() {
        return orderRemark;
    }

    public void setOrderRemark(String orderRemark) {
        this.orderRemark = orderRemark;
    }

    public String getIsMerge() {
        return isMerge;
    }

    public void setIsMerge(String isMerge) {
        this.isMerge = isMerge;
    }

    public String getIsGenBillNo() {
        return isGenBillNo;
    }

    public void setIsGenBillNo(String isGenBillNo) {
        this.isGenBillNo = isGenBillNo;
    }

    public String getMailno() {
        return mailno;
    }

    public void setMailno(String mailno) {
        this.mailno = mailno;
    }

    public String getMasterMailno() {
        return masterMailno;
    }

    public void setMasterMailno(String masterMailno) {
        this.masterMailno = masterMailno;
    }

    public String getDestCode() {
        return destCode;
    }

    public void setDestCode(String destCode) {
        this.destCode = destCode;
    }

    public String getAddedServiceName() {
        return addedServiceName;
    }

    public void setAddedServiceName(String addedServiceName) {
        this.addedServiceName = addedServiceName;
    }

    public String getAddedServiceValue() {
        return addedServiceValue;
    }

    public void setAddedServiceValue(String addedServiceValue) {
        this.addedServiceValue = addedServiceValue;
    }

    public String getAddedServiceValue1() {
        return addedServiceValue1;
    }

    public void setAddedServiceValue1(String addedServiceValue1) {
        this.addedServiceValue1 = addedServiceValue1;
    }

    public String getOrganizationCode() {
        return organizationCode;
    }

    public void setOrganizationCode(String organizationCode) {
        this.organizationCode = organizationCode;
    }

    public String getIsDocall() {
        return isDocall;
    }

    public void setIsDocall(String isDocall) {
        this.isDocall = isDocall;
    }

    /**
     * 初始化物流数据
     * @param commonData
     */
    public void initLogisticsData(LogisticsCommonData commonData) {
        //归还
        if(commonData.getBackUserAddress()!=null){
            //收件人
            LogisticsStoreCloudData storeCloudData = commonData.getStoreCloudData();
            //寄件人
            LogisticsBackUserAddressData backUserAddress = commonData.getBackUserAddress();

            // 门店ID，如果没有门店ID，则填写组织编码
            this.storeId = storeCloudData.getId() + "";


            //收件人
            this.dcontact = storeCloudData.getName();
            //收件电话
            this.dtel = storeCloudData.getStorePhone();
            //收件地址
            this.daddress = storeCloudData.getAddress();

            //寄件人 门店名称
            this.jcontact = backUserAddress.getUserName();
            //寄件电话 门店电话
            this.jtel = backUserAddress.getPhone();
            //寄件地址 门店云仓地址
            this.jaddress = backUserAddress.getAddress();
        }
        else{
            //收件人
            LogisticsUserData userData = commonData.getUserData();
            //寄件信息
            LogisticsStoreCloudData storeCloudData = commonData.getStoreCloudData();

            // 门店ID，如果没有门店ID，则填写组织编码
            this.storeId = storeCloudData.getId() + "";


            //收件人
            this.dcontact = userData.getName();
            //收件电话
            this.dtel = userData.getPhone();
            //收件地址
            this.daddress = userData.getAddress();

            //寄件人 门店名称
            this.jcontact = storeCloudData.getName();
            //寄件电话 门店电话
            this.jtel = storeCloudData.getStorePhone();
            //寄件地址 门店云仓地址
            this.jaddress = storeCloudData.getAddress();
        }

        //订单数据
        LogisticsOrderData orderData = commonData.getOrderData();
        //商品列表
        List<LogisticsGoodsData> goodsDataList = commonData.getGoodsDataList();

        //是否生成运单号  2：不生成运单号
        this.isGenBillNo = "1";
        //运单号
        this.mailno = "";
        //母单号
        this.masterMailno = orderData.getBigOrderSn();

        //大订单号 	客户订单号（箱号），可以多个拼接
        this.boxNo = orderData.getBigOrderSn();
        // 派单号 如没有，则填“客户订单号”
        this.dispatchNo = orderData.getBigOrderSn();

        //商品数量
        this.count = goodsDataList.size() + "";
        //托寄物
        this.cargo = "医疗护理设备";
        //支付方式 付款方式 1：寄方付 2：收方付 3:第三方付
        this.payMethod = "3";
        //产品类型 1：顺丰特快 2：顺丰标快等
        this.expressType = "2";
        LocalDateTime time = LocalDateTime.now();
        String curTime = time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        //客户支付时间 格式为：2019-04-21 14:42:27 如无支付时间，则当前时间
        this.custPayTime = curTime;


        //一小时内上门取件
        this.isDocall = "1";

    }
}
